<?php
declare (strict_types = 1);
namespace app\api\controller;

use think\facade\request;
use think\facade\Db;
use app\models\Clb;
use app\models\Jhb;
use app\models\Cpb;
use app\models\Xlb;
use app\models\Clb_bak;
use app\models\AutoSubmit;

use think\facade\Cache;

class baoban
{
 public function index(){
      echo "<center><h2>控制器方法功能注释</h2></center><hr>";
      echo "/是首页显示所有信息<hr>"; 
      echo "/baoban1是输入报班卡号，查询车辆是否已报停班，显示车辆基本信息  <hr>";
      echo "/baoban2是用baoban1查到的线路编号查询U_jhb的班次信息链表查询了检票口、班次编号等信息 <hr>";
      echo "/baoban3是给自动报班车辆报班，返回自动报班成功，不单独使用，配合/baoban4使用<hr>";
      echo "/baoban4是报班操作，已附加自动报班功能<hr>";
      echo "/baoban5是显示当前已报车辆列表 <hr>";
      echo "/baoban6是取消报班 条件判定<hr>";
      echo "/baoban7是取消报班操作事务操作<hr>";
      echo "/baoban8是加班验证 是否可以加班<hr>";
      echo "/baoban9是选择加班路线，调取U_xlb线路表，下拉选择路线<hr>";
      echo "/baoban10是加班的事务操作<hr>";
      echo "/baoban11是取消加班的条件判定<hr>";
      echo "/baoban12是取消加班的事务操作<hr>";
      echo "/baoban13是停班和解除停班的条件验证<hr>";
      echo "/baoban14是停班操作<hr>";
      echo "/baoban15是解除停班操作<hr>";
      echo "/baoban16是修改发车时间条件判断<hr>";
      echo "/baoban17是修改发车时间操作<hr>";
      echo "/baoban18是显示当前数据库时间<hr>";

  }
	//报班查询操作，输入报班卡号提示是否可以报班，如果可以显示出车牌照号、车主姓名、线路编号。
  public function baoban1(){
       $data = Request::instance()->post();

       // echo ($data['bbkh']); die;
		//$data['bbkh']='1234';
        $baoban1=Db::table('U_clb')
        ->where('bbkh',$data['bbkh'])
        ->field(['cpzh','czxm' ,'xlbh','bcbh'])
        ->select()
        ->toArray();
        
        foreach ($baoban1 as $key => $value1) {}
      
        $baoban =Db::table('U_clb')
        ->field('*')
        ->where('bbkh',$data['bbkh'])
        ->select();
        
        if(!count($baoban)){
        	return json([
                'code' => '1000007',
                'msg' => '未查询到车辆，请检查后输入',
            ]);
        }
        $baobanbak =Db::table('U_clb')
        ->field('cpzh,czxm,xlbh,bcbh')
        ->where('bbkh',$data['bbkh'])
        ->select();  
        
        foreach ($baoban as $key => $value) {}
        if($value['tbzt'] =='正常'){
          if($value['clzt']=='未报'){
            // echo  $baoban['cpzh'];  echo $value1['czxm'] ; echo $value1['xlbh'];
             //return json($baobanbak);
              return json([
                'code' => '01',
                'msg'  => '车辆已报班',
                'date' => $baobanbak,
            ]);
             //return $this->baoban3();
          }else{
               return json([
                'code' => '01',
                'msg' => '车辆已报班',
                'date' => $baobanbak,
            ]);
          }
        }else{
              return json([
                'code' => '1000007',
                'msg' => '车辆已停班',
            ]);
        }
       
      
    }
   // return $this->baoban2($asd)
 //报班2同时用刚才查到的线路编号查询U_jhb（行车计划表）的bcbh（班次号）、bclx(班次类型)、xlbh（线路编号）、xlmc(线路名称)、fcsj(发车时间)、jpk（检票口）、bczt（班次状态）查询后显示在下方。
   public function baoban2(){
   	 $data = Request::instance()->post();
       //$xlbh = request()->Input('xlbh');
   	  // $xlbh ='522';
   	  $bj=Db::table('U_jhb')
        ->field('ysbj')
        ->where('xlbh','=',$data['xlbh'])
        ->select();
        foreach ($bj as $key => $value) {
        	//var_dump($value['ysbj']);
        }
           if($value['ysbj']){
         $baoban1 =Db::table('U_jhb')
		->join('U_xlb','U_jhb.xlbh = U_xlb.xlbh')
        ->field('U_jhb.bcbh,U_jhb.xlbh,U_jhb.xlmc,U_jhb.ysfcsj as fcsj,U_jhb.bclx,U_jhb.bczt,U_xlb.jpk')
        ->where('U_jhb.xlbh','=',$data['xlbh'])
        ->where('U_jhb.bczt','=','未报')
        ->select();
        return json($baoban1);
        // return json([
        //         'code' => '01',
        //         'msg'  => '查询成功',
        //         'date' => $baoban1,
        //     ]);
           	// return 1;
           }else{
         $baoban2 =Db::table('U_jhb')
		->join('U_xlb','U_jhb.xlbh = U_xlb.xlbh')
        ->field('U_jhb.bcbh,U_jhb.xlbh,U_jhb.xlmc,U_jhb.fcsj,U_jhb.bclx,U_jhb.bczt,U_xlb.jpk')
        ->where('U_jhb.xlbh','=',$data['xlbh'])
        ->where('U_jhb.bczt','=','未报')
        ->select();
        return json($baoban2);
           // return json([
           //      'code' => '01',
           //      'msg'  => '查询成功',
           //      'date' => $baoban2,
           //  ]);

           }
        
     
     }
    //3.自动报班
  public function baoban3(){
  		$sj=Db::query('select sysdate() as sj;');
  		foreach ($sj as $key => $va) {}
        $baoban2=Db::table('U_autoSubmit')
        ->whereRaw( "bczt = '未报'and bbkh in (select bbkh from U_clb where clzt='未报')")
        ->where('bbsj','<',$va['sj'])
        ->select(); 
       //return $baoban2;
      if(count($baoban2))
      {
      foreach ($baoban2 as $key => $value) {}

         $zwgs=Db::table('U_clb')->where('bbkh',$value['bbkh'])->field('zwgs')->select();
          foreach ($zwgs as $k) {
          $zwgs = $k['zwgs']; }

        $data=[ 
          'U_clb.jpzt' => '未检',
          'U_clb.syzw' => $zwgs,
          'U_clb.clzt' => '已报',
          'U_clb.bclx' => '固定',
          'U_clb.bcbh' => $value['bcbh'],
          'U_clb.jpk'  => $value['jpk'],
          'U_clb.bbsj' => $va['sj'],
          'U_clb.fcsj' => $value['fcsj'],
        ];
      $baoban4= Db::table('U_clb')->where('bbkh',$value['bbkh'])->update($data);

      return $this->baoban3();
    }else{
      return json([
                'code' => '01',
                'msg' => '报班成功自动报班成功',
            ]);
    }

       }

   // 报班操作 报班4
    public function baoban4(){
    	 $date = Request::instance()->post();
          // $bbkh = request()->Input('bbkh');
          // $bcbh = request()->Input('bcbh');
          // $fcsj = request()->Input('fcsj');
    	   // $bbkh = '9005484';
        //    $bcbh = '0433';
        //    $fcsj = '2019-12-13 17:05:41';
          Db::startTrans();
           $jhb= Jhb::where('bcbh',$date['bcbh'])->update([
           
           'bbkh'      =>  $date['bbkh'],
           'real_time' =>  $date['fcsj'],
           'bczt'      =>  '已报',
        ]);
      		$sj=Db::query('select sysdate() as sj;');
  			foreach ($sj as $key => $va) {}
           $zwgs=Clb::where('bbkh',$date['bbkh'])->field('zwgs')->select();
	        foreach ($zwgs as $k) {
	          $b = $k['zwgs'];
	        }
        $clb= Clb::where('bbkh',$date['bbkh'])->update([

           'tpsl' => '0', 
           'jpzt' => '未检',
           // 'syzw' => $zwgs,
           'clzt' => '已报',
          // 'bclx' => '固定',
           'bcbh' => $date['bcbh'],
          // 'jpk'  => '2',
           'bbsj' => $va['sj'],
           'fcsj' => $date['fcsj'],
        ]);
       
        $result=Cache::store('redis')->exists($date['bbkh'].'_'.$date['fcsj']);
        // dump($result);
        if($result){
        	 $c =1;
        }else{
        	for ($i=1; $i<=$b; $i++) { 

                    $arr1[$i-1]=$i;               
                }
                $a=Cache::store('redis')->set($date['bbkh'].'_'.$date['fcsj'],$arr1);
                if($a){
                	 $c =1;
                }else{
                	 $c =0;
                }
        }
       
        if($jhb && $clb && $c ){
            
            DB::commit();
             
        }else{
           
            DB::rollback();
             return json([
                'code' => '1000007',
                'msg'  => '操作失败',
            ]);
            } 
            return $this->baoban3();
          }

     //显示已报车辆列表 加一个班次编号
      public function baoban5(){
       $baoban5 =Clb::join('U_xlb','U_clb.xlbh = U_xlb.xlbh')
      ->field(['U_xlb.jpk','U_clb.bbkh','U_clb.cpzh','U_clb.fcsj','U_clb.bbsj','U_clb.ssgs ','U_clb.czxm ','U_xlb.xlmc ','U_clb.xlbh' ,'U_clb.zwgs ','U_clb.jpzt','U_clb.bcbh'])
      ->where('U_clb.clzt','=','已报')
      ->select();
      return json($baoban5);
      }
      //取消报班 条件判定  
      public function baoban6(){
      	 $date = Request::instance()->post();
          // $bbkh = request()->Input('bbkh');
          // $bcbh = request()->Input('bcbh');
      	  // $bbkh = '9005484';
          // $bcbh = '0433';
        $baoban6 = Cpb::field('bbkh')
        ->where([
          'bcbh' => $date['bcbh'],
          'cpzt' => '正常',
          'jpfs' => '固定',
          'bbkh' => $date['bbkh'] ])  
        ->select();
        // return $baoban6; die;
        $clb = Clb::where('bbkh',$date['bbkh'])
        ->where('clzt','已报')
        ->select();
        //return $clb;
          $piao = count($baoban6);
          $clb = count($clb);
           // return $clb;
          if($piao ==0 && $clb ==1){
          	return $this->baoban7($date['bcbh']);
            
          }else{
          	 return json([
                'code' => '1000007',
                'msg'  => '条件不符不可以取消报班',
            ]);
           
          }
        }
     //取消报班操作事务操作  
     public function baoban7(){
     	$date = Request::instance()->post();
     	// $bbkh = '9001803';
         //事务
        Db::startTrans();
        $a=Clb::where([
        	'bbkh' =>  $date['bbkh'],
            'clzt' =>  '已报',
        ])
        ->update([  
            'clzt' => '未报',
            'tpsl' => '0',
            'bbsj' => null,
            'fcsj' => null,
        ]);
        
        $b=Jhb::where([
        	'bbkh' => $date['bbkh'],
        ])->update([  
            'bczt'     => '未报',
            'bbkh'     => '',
            'real_time'=> null,
        ]);
        if($a && $b){
            
            DB::commit();
             return json([
                'code' => '01',
                'msg'  => '操作成功取消报班',
            ]);
        }else{
            
            DB::rollback();
             return json([
                'code' => '1000007',
                'msg'  => '操作失败',
            ]);
            }
        }
        //
      public function baoban8X(){
          $data = Request::instance()->post();
          $xinxi = Clb::where('bbkh',$data['bbkh'])
          ->field('czxm,cpzh,ssgs,xlbh,zwgs,bclx')
          ->select();
          $tbzt=Clb::where(['bbkh'=>$data['bbkh']])
          ->field('tbzt')
          ->select();
          if(!count($tbzt)){
          return json([
                'code' => '1000007',
                'msg' => '未查询到车辆，请检查后输入',
            ]);
          }
            return json([
                'code' => '01',
                'msg'  => '可以加班',
                'date' => $xinxi,
            ]);
      }
      //加班验证 是否可以加班  
      public function baoban8(){
      	  //$bbkh = '9002714';
      	  $data = Request::instance()->post();
          $baoban8=Clb_bak::where('bbkh',$data['bbkh'])
          ->field('bbkh')
          ->select();
          $xinxi = Clb::where('bbkh',$data['bbkh'])
          ->field('czxm,cpzh,ssgs,xlbh,zwgs,bclx')
          ->select();

          $a= count($baoban8); 
          // echo $a;
          if($a==0){
            $a=1;
          }else{
            $a=0;
          };
          
          $tbzt=Clb::where(['bbkh'=>$data['bbkh']])
          ->field('tbzt')
          ->select();
          if(!count($tbzt)){
          return json([
                'code' => '1000007',
                'msg' => '未查询到车辆，请检查后输入',
            ]);
        }
          foreach ($tbzt as $key => $value) {
            $b=$value['tbzt'];
              // echo $b;
          }
           if($a && $b=='正常'){
            return json([
                'code' => '01',
                'msg'  => '可以加班',
                'date' => $xinxi,
            ]);
           }else
           return json([
                'code' => '1000007',
                'msg'  => '车辆已报班或已加班不可以加班',
            ]);
         }
         //选择加班路线，调取U_xlb线路表，下拉选择路线，
         public function baoban9(){
          $baoban9=Xlb::field(['xlbh','xlmc','jpk'])
          ->select();
          //return json($baoban9);
          return json([
                'code' => '10',
                'msg'  => '成功',
                'date' => $baoban9,
            ]);
         }
        //加班的事务操作
       public function baoban10(){
       	 // $bbkh = '9002714';
       	 // $xlbh = '201';
       	 // $jpk  = '5';
         $data = Request::instance()->post();
           //事务
          Db::startTrans();
          $baoban11=Clb::field('')
          ->where('bbkh',$data['bbkh'])
          ->select();
           
          foreach ($baoban11 as $key => $value) {}
          $a=Clb_bak::insert([
           'bbkh'   => $value['bbkh'],
           'czxm'   => $value['czxm'],
           'cpzh'   => $value['cpzh'],
           'zwgs'   => $value['zwgs'],
           'ssgs'   => $value['ssgs'],
           'xlbh'   => $value['xlbh'],
           'jpk'    => $value['jpk'],
           'bclx'   => $value['bclx'],
           'cldc'   => $value['cldc'],
           'clzt'   => $value['clzt'],
           'bcbh'   => $value['bcbh'],
           'bbsj'   => $value['bbsj'],
           'fcsj'   => $value['fcsj'],
           'tpsl'   => $value['tpsl'],
           'syzw'   => $value['syzw'],
           'jpzt'   => $value['jpzt'],
           'tbyy'   => $value['tbyy'],
           'acount' => $value['acount'],
           'tbzt'   => $value['tbzt'],
          ]);
        // echo($a); die;
        $b=Clb::where('bbkh',$data['bbkh']) ->update([
             'xlbh' => $data['xlbh'],
             'jpk'  => $data['jpk'],
          ]);
        if($a && $b){
            DB::commit();
             return json([
                'code' => '01',
                'msg'  => '加班操作成功',
            ]);
        }else{
            DB::rollback();
             return json([
                'code' => '1000007',
                'msg'  => '加班操作失败',
            ]);
            }
         }
       //取消加班的条件判定
      public function baoban11(){
      	//$bbkh = '9002714';
        $data = Request::instance()->post();
        $a=Clb_bak::where('bbkh',$data['bbkh'])
        ->field('bbkh')
        ->select();
        // echo $a;
        $b=Clb::where([
          'clzt' => '未报',
          'bbkh' => $data['bbkh'],
        ])
        ->field('bbkh')
        ->select();
        // echo $b;
        if (count($a)&& count($b)) {
            return 'cg';
           return $this->baoban12($date['bbkh']);
      }else{
      	return json([
                'code' => '1000007',
                'msg'  => '不可以取消加班,车辆未加班或者已报班',
            ]);
        
          }
      }  
      //取消加班的事务操作
      public function baoban12(){
      	//$bbkh = '9002714';
        $data = Request::instance()->post();
         //事务
        Db::startTrans();
      $a=Clb::where('bbkh',$data['bbkh'])->delete();
      $c=Clb_bak::field('')
          ->where(['bbkh'=>$data['bbkh']])
          ->select();
           foreach ($c as $key => $value) {
          $a=Clb::insert([
           'bbkh'   => $value['bbkh'],
           'czxm'   => $value['czxm'],
           'cpzh'   => $value['cpzh'],
           'zwgs'   => $value['zwgs'],
           'ssgs'   => $value['ssgs'],
           'xlbh'   => $value['xlbh'],
           'jpk'    => $value['jpk'],
           'bclx'   => $value['bclx'],
           'cldc'   => $value['cldc'],
           'clzt'   => $value['clzt'],
           'bcbh'   => $value['bcbh'],
           'bbsj'   => $value['bbsj'],
           'fcsj'   => $value['fcsj'],
           'tpsl'   => $value['tpsl'],
           'syzw'   => $value['syzw'],
           'jpzt'   => $value['jpzt'],
           'tbyy'   => $value['tbyy'],
           'acount' => $value['acount'],
           'tbzt'   => $value['tbzt'],
          ]);
          }
          $b=Clb_bak::where('bbkh',$data['bbkh'])->delete();
        if($a && $b && $c){
            
            DB::commit();
            return json([
                'code' => '1000007',
                'msg'  => '操作成功取消加班',
            ]);
        }else{
           
            DB::rollback();
             return json([
                'code' => '1000007',
                'msg'  => '操作失败',
            ]);

            }
      }
      //停班和解除停班的条件验证
      //bbkh和cpzh只能填一个进行查询

      
      public function baoban13A(){
        $data = Request::instance()->post();
      	//$bbkh='';
      	//$cpzh= '冀D47358';
       $a=Clb::where(['bbkh'=>$data['bbkh']])
       ->field('tbzt')->select();
         // echo $a;
        $tmp =count($a);
       		// echo $tmp;
        if($tmp){
          
        foreach ($a as $key => $value) {}
        $tbzt= $value['tbzt'];
        
        if($tbzt =='正常'){
          
           return json([
                'code' => '1000007',
                'msg'  => '该车辆状态正常可以停班',
                // 'date' => $data,
            ]);
        }else{
          
           return json([
                'code' => '1000007',
                'msg'  => '该车辆已停班可以取消停班',
                // 'date' => $date,
            ]);
        }
      }else{
         
           return json([
                'code' => '1000007',
                'msg'  => '输入信息有误请重新输入',
            ]);
        }
        }

        public function baoban13B(){
        $data = Request::instance()->post();
        //$bbkh='';
        //$cpzh= '冀D47358';
       $a=Clb::where(['cpzh'=>$data['cpzh']])
       ->field('tbzt')->select();
         // echo $a;
        $tmp =count($a);
          // echo $tmp;
        if($tmp){
          
        foreach ($a as $key => $value) {}
        $tbzt= $value['tbzt'];
        
        if($tbzt =='正常'){
          
           return json([
                'code' => '1000007',
                'msg'  => '该车辆状态正常可以停班',
                // 'date' => $data,
            ]);
        }else{
          
           return json([
                'code' => '1000007',
                'msg'  => '该车辆已停班可以取消停班',
                // 'date' => $date,
            ]);
        }
      }else{
         
           return json([
                'code' => '1000007',
                'msg'  => '输入信息有误请重新输入',
            ]);
        }
        }
         //停班操作
      public function baoban14A(){
        $data = Request::instance()->post();
      	//$bbkh='2271';
      	//$cpzh= '';
      	//$tbyy='长得丑';
        $baoban19=Clb::where(['bbkh'=>$data['bbkh']])
        ->update([
          'tbzt'=>'停运',
          'tbyy'=>$data['tbyy'],
        ]);
        
        if($baoban19){
          
          return json([
                'code' => '01',
                'msg'  => '停班操作成功',
            ]);
        }else{
          
          return json([
                'code' => '1000007',
                'msg'  => '停班操作失败',
            ]);
        }
      }
      //
      public function baoban14B(){
        $data = Request::instance()->post();
        //$bbkh='2271';
        //$cpzh= '';
        //$tbyy='长得丑';
        $baoban19=Clb::where(['cpzh'=>$data['cpzh']])
        ->update([
          'tbzt'=>'停运',
          'tbyy'=>$data['tbyy'],
        ]);
        
        if($baoban19){
          
          return json([
                'code' => '01',
                'msg'  => '停班操作成功',
            ]);
        }else{
          
          return json([
                'code' => '1000007',
                'msg'  => '停班操作失败',
            ]);
        }
      }
      //解除停班操作
      public function baoban15A(){
        $data = Request::instance()->post();
      	 // $bbkh='';
      	 // $cpzh= '冀D83677-';
         $baoban21=Clb::where(['bbkh'=>$data['bbkh']])
        ->update([ 'tbzt'=>'正常']);
          if($baoban21){
          
           return json([
                'code' => '1000007',
                'msg'  => '解除停班操作成功',
            ]);
        }else{
          
           return json([
                'code' => '1000007',
                'msg'  => '解除停班操作失败',
            ]);
        }
      } 
      //解除停班操作
      public function baoban15B(){
        $data = Request::instance()->post();
         // $bbkh='';
         // $cpzh= '冀D83677-';
         $baoban21=Clb::where(['cpzh'=>$data['cpzh']])
        ->update([ 'tbzt'=>'正常']);
          if($baoban21){
          
           return json([
                'code' => '1000007',
                'msg'  => '解除停班操作成功',
            ]);
        }else{
          
           return json([
                'code' => '1000007',
                'msg'  => '解除停班操作失败',
            ]);
        }
      } 

      //修改发车时间条件判断
      public function baoban16(){
      	$data = Request::instance()->post();
      	//$bbkh = '2362222';
       $sj=Db::query('select sysdate() as sj;');
  		foreach ($sj as $key => $va) {}
        $baoban22=Clb::where('bbkh' , $data['bbkh'])
    	->where('fcsj' ,'>' ,$va['sj'])   
        ->field('clzt')
        ->select();
        $baoban22bak=clb::where(['bbkh'=>$data['bbkh']])
        ->field('czxm,cpzh,ssgs,bbsj,fcsj')
        ->select();
         
          $a=count($baoban22);
          // echo ($a);die;
        if ($a){
          foreach ($baoban22 as $key => $value) {
            // echo $value->clzt;
          }
          // $b =$value['clzt'];
          // if($b=='已报'){
           // return json($baoban22bak);
            return json([
                'code' => '01',
                'msg'  => '可以修改发车时间',
                'date' => $baoban22bak
            ]);
          // }else{
          //   echo "车辆未报班不可修改发车时间";
          // }
        }else{
          
          return json([
                'code' => '1000007',
                'msg'  => '车辆没有报班或车辆已发车或没有该车辆信息',
            ]);

        }
      }
      //修改发车时间的数据操作
      public function baoban17(){
      	//$bbkh ='9002622';
      	//$fcsj ='2019-12-06 19:01:06';
      	$date = Request::instance()->post();

        Db::startTrans();
        $a=Clb::where(['bbkh' => $date['bbkh']])
        ->update([  
            'fcsj'=>$date['fcsj']
        ]);
        // echo($a); die;
        $b=Jhb::where(['bbkh' =>$date['bbkh'],
        ])->update([  
            'bczt'=>'已报',
            'real_time'=>$date['fcsj'],
        ]);
        if($a && $b){
            
            DB::commit();
             return json([
                'code' => '01',
                'msg'  => '操作成功',
            ]);
        }else{
            
            DB::rollback();
             return json([
                'code' => '1000007',
                'msg'  => '操作失败',
            ]);
            }
        }
      //输出当前数据库时间
       public function baoban18(){
       $sj=Db::query('select sysdate() as sj;');
  		foreach ($sj as $key => $va) {}
  			return $va['sj'];
  	}
  	public function ce(){
  		//$date = $_POST;

  		var_dump($_GET);
  		var_dump(Request::post());
  		$date = Request::instance()->post();
  		//return $date;
  		//return json($date);

  		return json([
  			 'code' => '1000007',
             'msg'  => '操作成功',
             'date' => $date,
  		]);
  	}
//验证过了，数据操作过了才能返回。
  	// public function ri(){
  	// 	Db::startTrans();
  	// 	$clb=Db::query("update U_clb set clzt='未报',bcbh=null,bbsj=null,fcsj=null,tpsl=0,syzw=0,jpzt='未检'");
  	// 	// $jhb=Db::query("update U_jhb set bbkh=null,bczt='未报',real_time=null,fcsj=convert(char,getdate(),111)+' '+convert(char,fcsj,108),xlmc=(select xlmc from U_xlb where U_jhb.xlbh=U_xlb.xlbh)");
  	// 	// $xlmc=Db::field('xlmc')->where('U_jhb.xlbh','U_xlb.xlbh');
  	// 	$jhb=Db::table('U_jhb')->where('1','1')
  	// 	->update([
  	// 		'bbkh'=> null,
  	// 		// 'bbsj'=> null,
  	// 		'fcsj'=> null,
  	// 		'bczt'=> '未报',
  	// 		'real_time'=> null,
  	// 		'fcsj' => Db::raw("convert(char,getdate(),111)+' '+convert(char,fcsj,108)"),
  	// 		'xlmc' => Db::raw("select xlmc from U_xlb where U_jhb.xlbh=U_xlb.xlbh"),
  	// 	]);
  	// 	$xlzdb=Db::query("update U_xlzdb set mdzm=(select mdzm from U_zdb where U_zdb.mdzh=U_xlzdb.mdzh)");
  	// 	$xlb=Db::query("update U_xlb set lssj=convert(char,getdate(),111)+' '+convert(char,lssj,108)");
  	// 	$auto=Db::query("update U_autosubmit set bczt='未报',bbsj=convert(char,getdate(),111)+' '+convert(char,bbsj,108),fcsj=convert(char,getdate(),111)+' '+convert(char,fcsj,108)");
  	// 	$clb1=Db::query("update U_clb set bclx=(select xllx from U_xlb where U_clb.xlbh=U_xlb.xlbh),jpk=(select jpk from U_xlb where U_clb.xlbh=U_xlb.xlbh)");
  	// 	$anto1=Db::query("update U_autosubmit set jpk=(select jpk from U_clb where U_clb.bbkh=U_autosubmit.bbkh)");
  	// 	if($clb && $jhb  && $xlzdb && $xlb && $auto && $clb1 && $anto1 ){
   //          echo "操作成功";
   //          DB::commit();
   //      }else{
   //          echo "操作失败";;
   //          DB::rollback();
   //          }
        

  	// }
     public function ceshi(){
       $baoban =Xlb::field(['xlbh','xlmc'])
      
      ->select();
      return json($baoban);
      }
      //当前已停班车辆查询
      public function baoban19(){
       $baoban =clb::field('*')
       ->where('tbzt','停运')
       ->select();
      return json($baoban);
      }
}
